Skip to content

update SP+EP - #209

Open
sfc-gh-mhidayetoglu wants to merge 87 commits into
merth/moe_epfrom
main
Open

update SP+EP#209
sfc-gh-mhidayetoglu wants to merge 87 commits into
merth/moe_epfrom
main

Conversation

@sfc-gh-mhidayetoglu

Copy link
Copy Markdown
Contributor

No description provided.

sfc-gh-truwase and others added 29 commits May 19, 2026 14:18
Signed-off-by: Stas Bekman <stas.bekman@snowflake.com>
Signed-off-by: Stas Bekman <stas.bekman@snowflake.com>
… (#76)

Co-authored-by: Ye Wang <ye.wang@snowflake.com>
Co-authored-by: Jeff Rasley <jeff.rasley@snowflake.com>
Co-authored-by: 151130f5470be3da5eea21fd02baa3_snow <bb9ecf6d788c5c0e03a13a6ec00039@snowflake.com>
Co-authored-by: Michael Wyatt <michael.wyatt@snowflake.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Compare sender HF names against the receiver model's expected set and fail
loud on mismatch so Qwen3-32B colocated runs catch architecture drift early.

Co-authored-by: Cursor <cursoragent@cursor.com>
- receiver: raise on incomplete CUDA IPC load (tensor-count mismatch),
  validate received parameter names on NCCL/CPU paths, and accept either
  serialized bytes or (name, tensor) pairs in load_weights_from_cpu
- replica_pool: raise RuntimeError when any worker's sync_weights status
  is not "done" instead of swallowing the failure
- api/multi_model: add /spec_weights_info and /sync_spec_weights endpoints
  plus Driver forwarding for multi-model mode

Co-authored-by: Cursor <cursoragent@cursor.com>
Add load_weights_cuda_ipc_chunk to the weight-sync receiver, which loads
one param (or small chunk) at a time from CUDA IPC handles instead of
requiring the whole model in one payload. It raises on any GPU missing a
handle and runs full param-name validation on the final chunk
(context=cuda_ipc_stream). Add the matching InferenceWorker
collective_rpc wrapper. This bounds peak extra GPU memory during sync to
one full param per GPU.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Stas Bekman <stas.bekman@snowflake.com>
Co-authored-by: Stas Bekman <stas.bekman@snowflake.com>
Comment on lines +100 to +123
@app.post("/init")
async def init_endpoint(request: InitRequest):
try:
n = await backend.initialize(
request.config, model_id=request.model_id,
num_replicas=request.num_replicas,
)
return {"status": "ready", "model_id": request.model_id, "num_replicas": n}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))


@app.post("/generate")
async def generate_endpoint(request: GenerateRequest):
try:
results = await backend.generate(**request.model_dump())
return {"results": results}
except RuntimeError as e:
msg = str(e).lower()
if "paused" in msg or "cancelled" in msg:
raise HTTPException(status_code=503, detail=str(e))
raise HTTPException(status_code=500, detail=str(e))
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Critical blocker

🔴 HIGH · FastAPI inference server exposes model init / generation / weight-sync endpoints with no authentication [NEW] · CWE-306

How to override this blocker

Resolve the finding and push, or override it:

  1. On this comment: add a 👎 reaction and post an inline reply disputing it.
  2. Add the critical_blocker_force_override label to the PR to trigger re-evaluation.

Every Critical blocker on the PR must be disputed this way — the label on its own does not override a blocker that has no 👎 and reply.

Comment on lines +136 to +139
data = path.read_bytes()
weights: list[tuple[str, torch.Tensor]] = torch.load(
io.BytesIO(data), map_location="cpu", weights_only=True,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MEDIUM · load_weights_from_shm uses torch.load on /dev/shm file (weights_only=True but attacker-writable path) [NEW] · CWE-502

Comment on lines +569 to +572
def load_weights_from_shm_path(self, path: str) -> dict:
"""Load weights from a shared memory file path."""
weights = torch.load(path, map_location="cpu", weights_only=True)
return self._load_cpu_weights_into_model(weights)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MEDIUM · load_weights_from_shm_path loads weights from a caller-supplied filesystem path via torch.load [NEW] · CWE-22

Comment on lines +473 to +474
handles_list = pickle.loads(
base64.b64decode(ipc_payload["ipc_handles_pickled"]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 Critical blocker

🔴 HIGH · load_weights_cuda_ipc deserializes attacker-influenced pickled IPC handles via pickle.loads [NEW] · CWE-502

How to override this blocker

Resolve the finding and push, or override it:

  1. On this comment: add a 👎 reaction and post an inline reply disputing it.
  2. Add the critical_blocker_force_override label to the PR to trigger re-evaluation.

Every Critical blocker on the PR must be disputed this way — the label on its own does not override a blocker that has no 👎 and reply.

Comment on lines +55 to +70
if is_server:
listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listen_socket.bind(("0.0.0.0", master_port))
listen_socket.listen()
listen_fd = listen_socket.fileno()

store = TCPStore(
host_name=master_addr,
port=master_port,
world_size=world_size,
is_master=is_server,
timeout=timedelta(seconds=300),
use_libuv=False,
master_listen_fd=listen_fd,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MEDIUM · stateless_init_nccl binds NCCL TCP rendezvous listener to 0.0.0.0 with no auth [NEW] · CWE-306

Comment on lines +24 to +30
class GenerateRequest(BaseModel):
model_id: str | None = None
prompts: list[str | list[int]]
sampling_params: dict[str, Any] = Field(default_factory=dict)
routing_key: str | list[str | None] | None = None
strict: bool = False

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 MEDIUM · GenerateRequest forwards arbitrary sampling_params dict to SamplingParams(**...) without validation · CWE-20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.